package com.peng.servlet;
import com.peng.entity.work;
import com.peng.service.impl.workServiceImpl;
import com.peng.service.workService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by 欧阳欣鹏 on 2018/8/14.
 */
public class WorkUpdServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        int a=Integer.parseInt(request.getParameter("a"));
        System.out.print(a);
        work w=new work();
        w.setWorkid(Integer.parseInt(request.getParameter("id")));
        w.setUserName(request.getParameter("userName"));
        w.setUserPhone(request.getParameter("uphone"));
        w.setUserAddress(request.getParameter("uaddress"));
        workService ws=new workServiceImpl();
        ws.update(w);
        if (a==1){
            response.sendRedirect("WorkIndexServlet?status=1&&workType=1");
        }
        if (a == 2) {
            response.sendRedirect("WorkIndexServlet?status=2&&workType=1");
        }
        if (a==3){
            response.sendRedirect("WorkIndexServlet?status=3&&workType=1");
        }
        }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
    }
}
